/**
 * 已废弃
 */
class pubLayaMe {
    constructor(type) {
        if (type === "upload") {
            this.uploadAll();
        }
    }

    uploadAll() {
        // 显示一个窗口
        let con = `
            <div class="common-tool-title">
                <div class="common-tool-icon-wrapper">
                    <img class="common-tool-icon" src="skins/default/image/ide/layamaker-newpro.png" style="width: 18px; height: 20px;">
                </div>
                <div class="common-tool-title-content"></div>
                #<div class="common-tool-close"></div>
            </div>
            <div>

            </div>
        `;
        let outter = document.createElement("div");
        outter.id = "publayame";
        outter.style = "";
        document.body.appendChild(outter);
        // this.msgHTML = document.getElementById("publayame").childNodes[2];
        return this.copy()
        .then(() => {
            debugger
        }).catch((err) => {
            showMessage(err.toString());
        });
    }

    showMessage(msg) {
        console.log(msg);
    }

    showProcess(process) {

    }

    copy() {
        const workspacePath = this.getWorkspaceRootPath();
        new Promise((resolve, reject) => {
            let gulpDir = path.join(__dirname, "../../../../../../", "node_modules", "gulp/bin/gulp.js");
            let gulpFile = path.join(__dirname,'publish_layame.js');
            let cmd = [`--gulpfile=${gulpFile}`, `--workspacePath="${workspacePath}"`, "pubLayaMe"];
            console.log(`%c ${cmd}`, "color: green;");
            let _fork = fork(gulpDir, cmd, {
                silent: true
            });
            _fork.stdout.on("data", (data) => {
                showMessage(data);
            });
            _fork.stderr.on("data", (err) => { // 出错
                showMessage(`${err}`);
            });
            _fork.on("close", () => {
                showMessage(`copy文件完成`);
            });
        }).catch((err) => {
            showMessage(`${err}`);
        });
    }

    screenshots() {

    }

    xlsx2Json() {

    }

    genConfigFile() {
        const configFileName = "";
    }
}

module.exports = pubLayaMe;